﻿using System;
using System.Collections.Generic;

/*
 * Write a program that reads a string from the console and lists all different
 * words in the string along with information how many times each word is found.
 */

namespace DifferentWords
{
    class DifferentWords
    {
        static void PrintResult(Dictionary<string, int> result)
        {
            foreach (KeyValuePair<string, int> word in result)
            {
                Console.WriteLine("{0} : {1}", word.Key, word.Value);
            }
        }

        static Dictionary<string, int> ExtractedWord(string text)
        {
            Dictionary<string, int> words = new Dictionary<string, int>();
            string[] wordsArray = text.Split(' ');

            foreach (string word in wordsArray)
            {
                if (words.ContainsKey(word))
                {
                    words[word]++;
                    continue;
                }
                words[word] = 1;
            }
                
            return words;
        }

        static void Main()
        {
            var result = ExtractedWord("test test test go6o go6o pe6o dragan");

            PrintResult(result);
        }
    }
}
